package com.bestcem.xm.txtanls.grpc.service.param.analysis;

import com.bestcem.xm.common.core.constant.RegTypes;
import com.bestcem.xm.txtanls.grpc.service.param.PageParam;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
 * 获取文本分析项目列表入参校验
 *
 * @author XiaoYunSong <ys.xiao@idiaoyan.com>
 * @version v1.0
 * @date 2021/5/10-15:21
 */
@NoArgsConstructor
@Getter
@Setter
public class ListAnalysisProjectParam {

    /**
     * 用户id
     */
    @NotBlank(message = ErrorMessage.USER_ID_ERROR)
    @Pattern(regexp = RegTypes.OBJECT_ID, message = ErrorMessage.USER_ID_ERROR)
    private String userId;

    /**
     * 组织id
     */
    @NotBlank(message = ErrorMessage.ORG_ID_ERROR)
    @Pattern(regexp = RegTypes.OBJECT_ID, message = ErrorMessage.ORG_ID_ERROR)
    private String orgId;

    /**
     * false: 根据用户id查询 | true: 根据组织id查询
     */
    private Boolean admin;

    /**
     * 文本分析项目名称查询条件
     */

    private String name;

    /**
     * 文本分析状态查询条件
     */
    private Integer status;

    /**
     * 项目名称
     */
    @Valid
    private PageParam pageParam;

    public ListAnalysisProjectParam(String userId, String orgId, Boolean admin, PageParam pageParam) {
        this.userId = userId;
        this.orgId = orgId;
        this.admin = admin;
        this.pageParam = pageParam;
    }

    public ListAnalysisProjectParam(String userId, String orgId, Boolean admin, String name, Integer status, PageParam pageParam) {
        this.userId = userId;
        this.orgId = orgId;
        this.admin = admin;
        this.name = name;
        this.status = status;
        this.pageParam = pageParam;
    }

    public static class ErrorMessage {
        public static final String USER_ID_ERROR = "用户id错误";
        public static final String ORG_ID_ERROR = "组织id错误";
        public static final String PAGE_PARAM_NULL_ERROR = "分页参数不能为空";
    }
}
